package com.zx.BookSeaReader.webapi;

import com.zx.BookSeaReader.callback.ResultCallback;
import com.zx.BookSeaReader.greendao.entity.Book;
import com.zx.BookSeaReader.util.crawler.BiQuGeReadUtil;

/**
 * @Author: ZX
 * @Time: 2020/4/15
 * @Description: 爬取小说
 */
public class BookStoreApi extends BaseApi{


    /**
     * 获取书城小说分类列表
     * @param url
     * @param callback
     */
    public static void getBookTypeList(String url, final ResultCallback callback){

        getCommonReturnHtmlStringApi(url, null, "GBK", new ResultCallback() {
            @Override
            public void onFinish(Object o, int code) {
                callback.onFinish(BiQuGeReadUtil.getBookTypeList((String) o),0);
            }

            @Override
            public void onError(Exception e) {
                callback.onError(e);

            }
        });
    }


    /**
     * 获取某一分类小说排行榜列表
     * @param url
     * @param callback
     */
    public static void getBookRankList(String url, final ResultCallback callback){

        getCommonReturnHtmlStringApi(url, null, "GBK", new ResultCallback() {
            @Override
            public void onFinish(Object o, int code) {
                callback.onFinish(BiQuGeReadUtil.getBookRankList((String) o),0);
            }

            @Override
            public void onError(Exception e) {
                callback.onError(e);

            }
        });
    }


    /**
     * 获取小说详细信息
     * @param book
     * @param callback
     */
    public static void getBookInfo(Book book, final ResultCallback callback){

        getCommonReturnHtmlStringApi(book.getChapterUrl(), null, "GBK", new ResultCallback() {
            @Override
            public void onFinish(Object o, int code) {
                callback.onFinish(BiQuGeReadUtil.getBookInfo((String) o,book),0);
            }

            @Override
            public void onError(Exception e) {
                callback.onError(e);

            }
        });
    }



}
